<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <input type="button" value="浪起来" @click="lang">
        <input type="button" value="低调" @click="bulang">
        <h4>{{msg}}</h4>
        <h4 v-text="msg"></h4>
    </div>
    <script src="../node_modules/vue/dist/vue.js"></script>
    <script>
        var vm = new Vue({
            el: "#app",
            data() {
                return {
                    msg: '猥琐发育，别浪```!',
                    intervalId:null
                }
            },
            methods: {
                lang() {
                    clearInterval(this.intervalId)
                    this.intervalId=setInterval(() => {
                        this.msg=this.msg.substr(1)+this.msg.substr(0,1) //尾+头
                    }, 400); 
                    //箭头函数内部this永远和箭头函数外部的this保持一致。这里外部this是vm Vue实例
                },
                bulang() {
                    clearInterval(this.intervalId)
                }
            }
        })
    </script>
</body>

</html>